package com.gzx.spring.drools.controller;

import com.gzx.risk.core.pojo.CommonResult;
import com.gzx.risk.core.tags.CommonLog;
import com.gzx.spring.drools.service.RiskWorkService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "drools")
@RestController
@Validated
@RequestMapping("/api/risk")
@Slf4j
public class DroolsApiController {
	@Resource
	private RiskWorkService riskWorkService;

	@Operation(summary = "riskOrder")
	@CommonLog("riskOrder")
	@GetMapping("/riskOrder")
	public CommonResult<Boolean> riskOrder(@RequestParam(name = "orderid") Integer orderid) throws Exception {
		log.info("开始风控流程:{}", orderid);
		return CommonResult.data(riskWorkService.exec(orderid));
	}

    @Operation(summary = "riskTwo_Order")
    @CommonLog("riskTwo_Order")
    @GetMapping("/riskTwo_Order")
    public CommonResult<Boolean> riskTwo_Order(@RequestParam(name = "orderid") Integer orderid) throws Exception {
        log.info("开始风控二阶段流程:{}", orderid);
        return CommonResult.data(riskWorkService.execRiskTwo(orderid));
    }

	@GetMapping("/hello")
	public CommonResult<String> hello() throws Exception {
		return CommonResult.data("good");
	}
}
